package com.jia.leetCode;

/**
 * @program: Leetcode
 * @description:
 * @author: STU756
 * @create: 2020-08-16 22:03
 */
public class Pro0137 {
    //Time:O(32*n) Space:O(1)
    public int singleNumber(int[] nums) {
        int ans = 0;
        //统计没一位1的个数，如果为3整除，那么单独数字在该位为0，否则为1
        for(int i = 0; i < 32; i ++) {
            int countBit2One = 0;
            for(int num : nums) {
                countBit2One += (num >> i) & 0x1;
            }
            ans += (countBit2One % 3) << i;
        }
        return ans;
    }
}
